<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller{
	function index(){
		$this->display();
	}
	function  Verify(){
		ob_clean();
		$ob=new \Think\Verify();
		$ob->fnotSize = 15;
		$ob->length=1;
		$ob->imageH=40;
		$ob->imageW=180;
		$ob->entry();
	}
	function check(){
		$admin = new \Think\Model('admin');
		//接收表单数据
		$username = $_POST['username'];
		$password = $_POST['password'];
		//查询
		$re = $admin->where("username='%s' and password='%s'", array($username, $password))
			->find();
		//判断 如果有 创建会话变量 跳转后台首页
		if ($re) {
			$_SESSION['adminid'] = $re['id'];
			$_SESSION['username'] = $username;
			$this->success("登录成功", U("Index/index"));
		} else {
			//否则提示错误，跳转到登录
			$this->error("用户名或密码错误", U("Login/index"));
		}
	}
}